Release 10.1A: OpenEdge Development:
ADM and SmartObjects
Creating the myviewer class
The example in this section illustrates creating a new class based on the viewer class. The new class, called myviewer, will contain custom functionality that displays a warning message to an application user who wants to delete a record and allows the user to choose how to proceed. This functionality will be built into all SmartObjects based on this class.
The following sections describe how to create the new myviewer class files, then modify them to create the new functionality.
Note: The example assumes you installed Progress in theD:\PROGRESSdirectory.Creating the myviewer class files
![]()
To create the myviewer class files:
- From the AppBuilder main menu, choose Tools
New ADM Class...:
![]()
The New ADM Class dialog box opens, with the Basic tab in front.
- In the Name field, enter myviewer, the new class name:
![]()
When you type myviewer, the AppBuilder enters default directories in the directory fill-in fields and names based on myviewer in many of the filename fill-in fields; for example,
myviprop.ifor the property filename.- Select the class from which to derive the myviewer class:
- Click on the Class button next to the Derive From Class field. In the Choose Class Definition dialog box that appears, you are placed by default in the
%DLC%\src\adm2(Windows) or$DLC/src/adm2(UNIX) directory.- Select the
viewer.cldclass definition file in that directory, then choose Open.The AppBuilder adds information to the New ADM Class dialog box:
![]()
The Derive From Class field now contains the
viewer.cldclass definition file. The the Copy From Template field automatically is filled with the filename of the viewer template. This happens only because the class definition file contains a definition of this template; if it did not, this field would stay empty.- Click the Custom Files tab to note the custom class files that will be generated for the
myviewerclass:
![]()
- Click the Basic tab, then check the Open files in the AppBuilder once generated check box. This instructs the AppBuilder to open the primary include file, the property file, the super procedure file, and the prototype file after creating the class files:
![]()
- Press OK to create the files.
- After the AppBuilder finishes creating the myviewer class files, close the primary include file (
myviewer.i) and the prototype file (myviprto.i). In this example, these files do not need modification.Modifying the myviewer standard class files
You use the following new code to implement the custom myviewer functionality: a
DeleteMessageproperty, asetDeleteMessagefunction, and an override procedure for the standard ADMdeleteRecordmethod. Adding this functionality requires changes only to themyviprop.iproperty file and themyviewer.psuper procedure file, both of which should still be open in the AppBuilder.
![]()
To add the new functionality in the AppBuilder:
- Define the new
DeleteMessageproperty in themyviprop.iproperty file.
To do this, go to the file’s main block and add the code shown in bold typeface below:
When you finish making these changes, click on the Save button (the diskette icon) on the AppBuilder main window to save your changes, then close the property file window.
- Create a new
setDeleteMessagefunction in themyviewer.psuper procedure file.
This function allows you to set the newDeleteMessageproperty. To create the new function, add the code shown in bold typeface:
- Create a new override procedure for the
deleteRecordmethod in themyviewer.psuper procedure file. This procedure displays an alert box when thedeleteRecordmethod is invoked; this alert box prompts the user with a message that corresponds to the value of the newDeleteMessageproperty: if the user chooses Yes, the ADMdeleteRecordexecutes, otherwise it returns without executing. To create the new override procedure, add the code shown in bold typeface:
When you finish making the changes in Step 2 and Step 3, click on the Save button (the diskette icon) on the AppBuilder main window to save your changes, then close the super procedure file window. The AppBuilder now creates a
.rversion of the super procedure in thesrc\adm2directory under your working directory.Note: If you do not move the- Enable the new super procedure file by moving the
.rfile from thesrc\adm2directory under your working directory into theadm2directory under your working directory..rfile into theadm2directory under your working directory, you will not be able to use the new super procedure.- Make the template for the myviewer class available on the New dialog box that appears when you choose File
New from the AppBuilder menu. To do this:
The new class, with its custom behavior, is now ready for use. Before you work with it, you should restart the AppBuilder to re-establish the super procedure stack.
|
Copyright © 2005 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095 |